Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compilation error on gcc 14.2 #2421

Closed
wants to merge 1 commit into from
Closed

Conversation

djhshih
Copy link

@djhshih djhshih commented Aug 8, 2024

R

devtools::install()

Compilation error encountered with gcc 14.2:

In file included from gdal.cpp:1:
./gdal.h:3:1: error: ‘OGRSpatialReference’ does not name a type; did you mean ‘DEFINED_OGRSpatialReferenc
eH’?
    3 | OGRSpatialReference *handle_axis_order(OGRSpatialReference *sr);
      | ^~~~~~~~~~~~~~~~~~~
      | DEFINED_OGRSpatialReferenceH
./gdal.h:4:1: error: ‘Rcpp’ does not name a type
    4 | Rcpp::List create_crs(const OGRSpatialReference *ref, bool set_input);
      | ^~~~

This commit forward declares OGRSpatialReference to fix the first error above, and it includes Rcpp.h explicitly to fix the second error.

$ R --version
R version 4.4.1 (2024-06-14) -- "Race for Your Life"

$ gcc --version
gcc (GCC) 14.2.1 20240802

$ uname -a
Linux durus 6.10.3-arch1-1 #1 SMP PREEMPT_DYNAMIC Sun, 04 Aug 2024 05:11:32 +0000 x86_64 GNU/Linux

R
> devtools::install()

Compilation error encountered with gcc 4.2:

```
In file included from gdal.cpp:1:
./gdal.h:3:1: error: ‘OGRSpatialReference’ does not name a type; did you mean ‘DEFINED_OGRSpatialReferenc
eH’?
    3 | OGRSpatialReference *handle_axis_order(OGRSpatialReference *sr);
      | ^~~~~~~~~~~~~~~~~~~
      | DEFINED_OGRSpatialReferenceH
./gdal.h:4:1: error: ‘Rcpp’ does not name a type
    4 | Rcpp::List create_crs(const OGRSpatialReference *ref, bool set_input);
      | ^~~~
```

This commit forward declares `OGRSpatialReference` to fix the first
error above, and it includes `Rcpp.h` explicitly to fix the second
error.

```
$ R --version
R version 4.4.1 (2024-06-14) -- "Race for Your Life"

$ gcc --version
gcc (GCC) 14.2.1 20240802

$ uname -a
Linux durus 6.10.3-arch1-1 r-spatial#1 SMP PREEMPT_DYNAMIC Sun, 04 Aug 2024 05:11:32 +0000 x86_64 GNU/Linux
```
@rsbivand
Copy link
Member

@djhshih Please indicate which version of GDAL you are using. I cannot replicate with GCC 14.2.1 (current Fedora 40) for:

$ gdalinfo --version
GDAL 3.9.1, released 2024/06/22

GDAL 3.9.2 RC was made available yesterday with a further fix for GCC 14.2: https://github.com/OSGeo/gdal/blob/v3.9.2RC1/NEWS.md

@djhshih
Copy link
Author

djhshih commented Aug 13, 2024

$ gdalinfo --version
GDAL 3.9.1, released 2024/06/22

@rsbivand
Copy link
Member

@djhshih How were R and GDAL installed? I always install from source, but if you use a package manager, it may arbitrarily impose CFLAGS that max out the package manager's choice of what is felt to be secure. My CFLAGS as shown in running R CMD INSTALL (please always avoid devtools as it and RStudio insert layers of indeterminacy):

configure: Package CPP flags:  -I/usr/local/include -I/usr/include/webp -DWITH_GZFILEOP -DHAVE_PROJ_H -I/usr/local/include -I/usr/local/include
configure: Package LIBS: -L/usr/local/lib64 -lproj   -L/usr/local/lib64 -lgdal -L/usr/local/lib64 -lgeos_c
...
g++ -std=gnu++17 -I"/home/rsb/topics/R/R441-share/lib64/R/include" -DNDEBUG -I/usr/local/include -I/usr/include/webp -DWITH_GZFILEOP -DHAVE_PROJ_H -I/usr/local/include -I/usr/local/include -I'/home/rsb/lib/r_libs/Rcpp/include' -I/usr/local/include    -fpic  -g -O2   -c gdal.cpp -o gdal.o

Yours are?

@edzer
Copy link
Member

edzer commented Aug 25, 2024

We're not yet testing with gcc 14 I believe, but these fixes seem odd and unnecessary to me.

@rsbivand
Copy link
Member

@edzer I did test, as F40 has 14.2.1. The problem is most likely that Arch Linux binary builds of R impose specific, possibly aggressive, C/CXXFLAGS (unknown, @djhshih did not reply) that change the behaviour of the build train. I don't see any problems with default flags. This is up to the user, I think. @djhshih needs to document the flags used here, both for building GDAL etc., and R, and those that R CMD config emits in configure when installing sf.

@edzer edzer closed this Nov 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants